package com.example.hibernate.c.defaultValue;

import org.hibernate.Session;
import org.junit.Test;

import com.example.hibernate.utils.HibernateUtils;

public class TestApp {
	
	@Test
	public void testSaveAndGet(){
		
		Article article = new Article();
		article.setTitle("ssssssssssss");
		
		Session session = HibernateUtils.openSession();
		session.beginTransaction();
		
		session.save(article);
		
		session.getTransaction().commit();
		
		//-----------------------------
		
		session = HibernateUtils.openSession();
		session.beginTransaction();
		
		Article a = (Article) session.get(Article.class, article.getId());
		
		session.getTransaction().commit();
		
		System.out.println(a);
	}
	
	@Test
	public void testUpdate(){
		Session session = HibernateUtils.openSession();
		session.beginTransaction();
		
		Article a = (Article) session.get(Article.class, 6L);
		a.setStyle(9);
		
		session.getTransaction().commit();
	}
}
